home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / EndScreen.as < prev    next >
Text File  |  2013-04-24  |  4KB  |  102 lines

  1. class EndScreen extends State
  2. {
  3.    static var sSTATE_IN = "In";
  4.    static var sSTATE_IDLE = "Idle";
  5.    static var sSTATE_OUT = "Out";
  6.    static var nFIRST_VISIBLE_FRAME = 15;
  7.    function EndScreen(_mcRef)
  8.    {
  9.       super(_mcRef);
  10.       this.setState(EndScreen.sSTATE_IN);
  11.       this.bRestartButton = false;
  12.       this.nFinalScore = CTRLGame.getRef().Score;
  13.       this.sUnit = " points!";
  14.       if(this.nFinalScore == 0 || this.nFinalScore == 1)
  15.       {
  16.          this.sUnit = " point!";
  17.       }
  18.    }
  19.    function doPause()
  20.    {
  21.    }
  22.    function doUnPause()
  23.    {
  24.    }
  25.    function In()
  26.    {
  27.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  28.       if(this.stateFinished())
  29.       {
  30.          this.setState(EndScreen.sSTATE_IDLE);
  31.          this.initScreen();
  32.          this.mcRef.mcState.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  33.       }
  34.       else if(this.mcRef.mcState._currentframe == EndScreen.nFIRST_VISIBLE_FRAME)
  35.       {
  36.          Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcScreen.mcSubmit);
  37.          this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  38.          if(Main.getRef().sState == Main.sSTATE_WIN)
  39.          {
  40.             Controller.getRef().getSounds().playSound("WinScreen_In",Controller.nSFX_VOLUME,1);
  41.          }
  42.          else if(Main.getRef().sState == Main.sSTATE_LOSE)
  43.          {
  44.             Controller.getRef().getSounds().playSound("LoseScreen_In",Controller.nSFX_VOLUME,1);
  45.          }
  46.       }
  47.    }
  48.    function Idle()
  49.    {
  50.    }
  51.    function Out()
  52.    {
  53.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  54.       if(this.stateFinished())
  55.       {
  56.          this.mcRef.mcState.stop();
  57.          if(this.bRestartButton)
  58.          {
  59.             Main.getRef().onRestartButton();
  60.          }
  61.          else
  62.          {
  63.             Main.getRef().onHighScoresButton();
  64.          }
  65.       }
  66.    }
  67.    function clickRestartButton()
  68.    {
  69.       Controller.getRef().playClickSound();
  70.       this.bRestartButton = true;
  71.       this.setOut();
  72.    }
  73.    function clickHighScoresButton()
  74.    {
  75.       Controller.getRef().playClickSound();
  76.       this.bRestartButton = false;
  77.       this.setOut();
  78.    }
  79.    function setOut()
  80.    {
  81.       this.setState(EndScreen.sSTATE_OUT);
  82.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcScreen.mcSubmit);
  83.       Controller.getRef().getSounds().startFadeOut("WinScreen_In");
  84.       Controller.getRef().getSounds().startFadeOut("LoseScreen_In");
  85.       Controller.getRef().getSounds().playSound("EndScreen_Out",Controller.nSFX_VOLUME,1);
  86.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  87.    }
  88.    function initScreen()
  89.    {
  90.       this.mcRef.mcState.btnPlayAgain.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  91.       this.mcRef.mcState.btnPlayAgain.onRelease = Delegate.create(this,this.clickRestartButton);
  92.       this.mcRef.mcState.btnHighScores.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  93.       this.mcRef.mcState.btnHighScores.onRelease = Delegate.create(this,this.clickHighScoresButton);
  94.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcSubmit);
  95.       if(this.mcRef.mcState.mcSubmit._visible)
  96.       {
  97.          this.mcRef.mcState.mcSubmit.btnSubmit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  98.          this.mcRef.mcState.mcSubmit.btnSubmit.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickSubmitScore);
  99.       }
  100.    }
  101. }
  102.